<?
@session_start();

require_once("conn.php");
?>

<input type="button" value="Check Out" onclick="testCheckOut()"><br>
<table width="100%">
	<?
		$unit = '';
		
			
				$sqlP = "SELECT * FROM pch_unit ORDER BY unit_name;";
				$queryP = mysql_query($sqlP);
				while($rowP = mysql_fetch_array($queryP)){
					$unit .= '<option value="'.$rowP["id"].'">'.$rowP["unit_name"].'</option>';
				}




	$sql = "SELECT * FROM pch_category WHERE id<>'2';";
	$query = mysql_query($sql);
	while($row = mysql_fetch_array($query)){
	?>
	<tr>
		<td colspan="8" style="text-align:center;font-weight:bold;font-size:17px;background-color:#99D9EA"><?=$row["category_name"]?></td>
	</tr>
	<tr>
		<td>&nbsp;</td>
		<td style="font-weight:bold;">Product</td>
		<td style="text-align:center;font-weight:bold;"><span style="color:red;">Q</span></td>
		<td style="text-align:center;font-weight:bold;">Unit</td>
		<td>&nbsp;</td>
		<td style="font-weight:bold;">Product</td>
		<td style="text-align:center;font-weight:bold;"><span style="color:red;">Q</span></td>
		<td style="text-align:center;font-weight:bold;">Unit</td>
	<tr>
	<?	
		$pcount = 1;
		if($_SESSION["language"] == "TH"){
			$sql = "SELECT * FROM pch_product WHERE category_id='".$row["id"]."' ORDER BY product_name ASC;";
		}else{
			$sql = "SELECT a.id as id,IF(mm = '', th, mm) as product_name,barcode,category_id,image FROM pch_product as a join pch_product_language as b on a.id=b.product_id WHERE category_id='".$row["id"]."' ORDER BY product_name ASC;";
		}
		//$sql = "SELECT * FROM pch_product WHERE category_id='".$row["id"]."' ORDER BY product_name ASC;";
		$pquery = mysql_query($sql);
		while($prow = mysql_fetch_array($pquery)){
		?>
			<td style="width:10px;text-align:center;"><input type="checkbox" class="checkboxSelector" id="check_<?=$prow["id"]?>"></td>
			<td style="width:100px;"><?=$prow["product_name"]?></td>
			<td style="width:8px;text-align:center;"><input type="checkbox" class="quickSelector" id="quick_<?=$prow["id"]?>"></td>
			<td style="width:60px;text-align:center;"><input type="text" class="amountSelector" id="amount_<?=$prow["id"]?>" style="width:40px;height:18px;"><select id="unit_<?=$prow["id"]?>" style="height:20px;"><option value="">&nbsp;</option><?=$unit?></select></td>
			
		<?
			if($pcount % 2 == 0){
				echo "</tr><tr>";
			}
			$pcount++;
		}
	?>
	</tr>
	<?
	}
	?>
</table><br>
<input type="button" value="Check Out" onclick="testCheckOut()">